/*
 * COPYRIGHT. ShenZhen MinSiDa Technology Co., Ltd. 2018.
 * ALL RIGHTS RESERVED.
 *
 * No part of this publication may be reproduced, stored in a retrieval system, or transmitted,
 * on any form or by any means, electronic, mechanical, photocopying, recording, 
 * or otherwise, without the prior written permission of ShenZhen MinSiDa Technology Co., Ltd.
 *
 * Amendment History:
 * 
 * Date                   By              Description
 * -------------------    -----------     -------------------------------------------
 * 2018年12月20日    LiChuanJi         Create the class
*/

package com.jungle.sp.daily.util;

import org.junit.Test;

import java.util.HashMap;
import java.util.Map;


/**
 * @FileName CreateOrderControllerTest.java
 * @Description: 
 *
 * @Date 2018年12月20日 
 * @author LiChuanJi
 * @version 1.0
 * 
 */
public class WarehouseingOrderControllerTest {
	//本机测试地址
	//	public static String url="http://localhost:8080/e3mf-order-api-module/api.do";

	//测试地址
	public static String url = "http://183.3.221.237:22226/fscc-api/api.do";
	public static String charset = "UTF-8";


	@Test
	public  void retrieval() {
		    	String method="order.retrieval";

		    	String data = "{\"parameter\":{\"orderNo\":\"20180001245555\",\"orderType\":\"201\",\"operateType\":1,\"warehouseName\":\"风神仓库\",\"warehouseCode\":\"888888\",\"senderCusCode\":\"FS001\",\"senderCusName\":\"风神\",\"receiverCusCode\":\"revice001\",\"receiverName\":\"收件人\",\"receiverProv\":\"广东省\",\"receiverCity\":\"东莞市\",\"receiverArea\":\"北区\",\"receiverAddr\":\"口水镇赖新小学\",\"receiverPhone\":\"0762-8963221\",\"receiverMobile\":\"13800138000\",\"orderDateTime\":\"2019-05-21 15:54:11\",\"logisticsNo\":\"8888888888\",\"remark\":\"测试修改数据\",\"totalPcs\":20,\"totalWeight\":69.1,\"expressCompany\":\"飞梭物流\",\"items\":[{\"sku\":\"sku001\",\"extSku\":\"extsku001\",\"batchNo\":\"HQQ001\",\"quantity\":3,\"brandName\":\"宝马\",\"remark\":\"备注\"},{\"sku\":\"sku001\",\"extSku\":\"extsku001\",\"batchNo\":\"HQQ001\",\"quantity\":3,\"brandName\":\"宝马\",\"remark\":\"备注\"},{\"sku\":\"sku001\",\"extSku\":\"extsku001\",\"batchNo\":\"HQQ001\",\"quantity\":3,\"brandName\":\"宝马\",\"remark\":\"备注\"},{\"sku\":\"sku001\",\"extSku\":\"extsku001\",\"batchNo\":\"HQQ001\",\"quantity\":3,\"brandName\":\"宝马\",\"remark\":\"备注\"},{\"sku\":\"sku001\",\"extSku\":\"extsku001\",\"batchNo\":\"HQQ001\",\"quantity\":3,\"brandName\":\"宝马\",\"remark\":\"备注\"}]}}";

				try {
					String sign=HttpUtils.encrypt(data, "2FJ73C95FFTK7Z4B", "UTF-8");
					 
					System.out.println("签名："+sign);
					Map<String, String> params = new HashMap<String, String>();
					params.put("v", "1.0");
					params.put("method", method);
					params.put("format", "json");
					params.put("sign", sign);
					params.put("data", data);
					params.put("sessionid", "1000000000001");
					params.put("devices", "NO_SIGN");

					String result = HttpPostUtil.postRequest(url,params);
					System.out.println(result);
				} catch (Exception e) {
					e.printStackTrace();
				}
	}

	@Test
	public void retrievalCancelTest(){

		String method="order.retrievalCancel";

		String data = "{\"parameter\":{\"orderNo\":\"201800012455556\"}}";

		try {
			String sign=HttpUtils.encrypt(data, "2FJ73C95FFTK7Z4B", "UTF-8");

			System.out.println("签名："+sign);
			Map<String, String> params = new HashMap<String, String>();
			params.put("v", "1.0");
			params.put("method", method);
			params.put("format", "json");
			params.put("sign", sign);
			params.put("data", data);
			params.put("sessionid", "1000000000001");
			params.put("devices", "NO_SIGN");

			String result = HttpPostUtil.postRequest(url,params);
			System.out.println(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
